define(['../../carrys/cityList','../../carrys/jsonList','../../../../js/lib/other/sweet-alert'],function(cityData,jsonList) {
    return ['$scope','$location', '$interval','$timeout','bizProxy', function($scope,$location,$interval,$timeout,bizProxy) {
        $scope.$emit("top-show",'true');//顶部显示
        $scope.$emit('menuTypeLight','loan'); 	//控制底部menu高亮
        $scope.$emit('bub-menu','true'); 	//隐藏底部menu
        $scope.$emit('flag-tag','73-0'); 	//显示底部文字

        $scope.show_caseNo=false;
        if(transData.userType === '1' ){
            $scope.show_isSpecLawyer=false;
            $scope.show_lawyerNo=true;
        }else{
            $scope.show_isSpecLawyer=true;
            $scope.show_lawyerNo=false;
        }
        $scope.disabled_userName=resultData.loginUserData.userName?true:false;
        $scope.disabled_idType=resultData.loginUserData.idType?true:false;
        $scope.disabled_idNo=resultData.loginUserData.idNo?true:false;
        $scope.disabled_lawyerNo=resultData.loginUserData.lawyerNo?true:false;
        $scope.disabled_lawfirmName=resultData.loginUserData.lawfirmName?true:false;
        $scope.step1=true;
        $scope.step2=false;
        $scope.step3=false;
        $scope.step4=false;
        $scope.userName=resultData.loginUserData.userName;
        $scope.idType=resultData.loginUserData.idType;
        $scope.idNo=resultData.loginUserData.idNo;
        $scope.lawyerNo=resultData.loginUserData.lawyerNo;
        $scope.lawfirmName=resultData.loginUserData.lawfirmName;
        $scope.mobileNo=resultData.loginUserData.mobileNo;
        var setStep=function (step) {
            $timeout(function () {
                $scope.step1=false;
                $scope.step2=false;
                $scope.step3=false;
                $scope.step4=false;
                $scope['step'+step]=true;
                if(step!=='1'){
                    $scope.$emit('flag-tag','73');
                }
            });
        }
        //点击个人信息
        $scope.goPersonalInfo = function(){
            if(resultData.loginUserData != "" && resultData.loginUserData != null){
                if(resultData.loginUserData.idNo != "" && resultData.loginUserData.idNo != null){
                    $timeout(function(){
                        $scope.$emit("goNext","/personalInfo");
                    },300);
                }else{
                    $timeout(function(){
                        // $scope.$emit("goNext","/completePtData");
                        $scope.$emit("goNext","/completeData");
                    },300);
                }
            }else{
                $timeout(function(){
                    // $scope.$emit("goNext","/completePtData");
                    $scope.$emit("goNext","/completeData");
                },300);
            }
        }
        $scope.change_caseStageId=function () {
            var list=transData.storage_baseData.queryCaseStageList.caseStageList;
            for(var i=0;i<list.length;i++){
                if(list[i].caseStageId==$scope.caseStageId){
                    $timeout(function () {
                        if(list[i].caseStageName==='未立案'){
                            $scope.show_caseNo=false;
                            if(document.querySelector('#caseNo_expectClosePeriod_con')){
                                document.querySelector('#caseNo_expectClosePeriod_con').style.height='0px'
                            }
                        }else {
                            $scope.show_caseNo=true;
                            if(document.querySelector('#caseNo_expectClosePeriod_con')){
                                document.querySelector('#caseNo_expectClosePeriod_con').style.height='104px'
                            }
                        }
                        if(list[i].caseStageName==='执行'){
                            if(document.querySelector('#judgeName_havePropertyClue_con')){
                                document.querySelector('#judgeName_havePropertyClue_con').style.height='156px'
                            }
                        }else {
                            if(document.querySelector('#judgeName_havePropertyClue_con')){
                                document.querySelector('#judgeName_havePropertyClue_con').style.height='0px'
                            }

                        }
                    })
                    break
                }
            }
        }
        $scope.change_isSpecLawyer=function () {
            if($scope.isSpecLawyer==='Y'){
                if(document.querySelector('#isSpecLawyer_con')){
                    document.querySelector('#isSpecLawyer_con').style.height='104px'
                }
            }else {
                if(document.querySelector('#isSpecLawyer_con')){
                    document.querySelector('#isSpecLawyer_con').style.height='0px'
                }
            }
        }
        $scope.nextStep=function (nextStep) {
            if(nextStep==='done'){
                history.back()
            }else if(nextStep==='2'){
                if(transData.userType === '1' ){
                    if(!$scope.disabled_userName||!$scope.disabled_idType||!$scope.disabled_idNo||!$scope.disabled_lawyerNo||!$scope.disabled_lawfirmName){
                        if(!$scope.disabled_userName){
                            if(!$scope.userName){
                                showCheck('请输入姓名');
                                return;
                            }
                        }
                        if(!$scope.disabled_idType){
                            if(!$scope.idType){
                                showCheck('请选择证件类型');
                                return;
                            }
                        }
                        if(!$scope.disabled_idNo){
                            if(!$scope.idNo){
                                showCheck('请输入证件号');
                                return;
                            }
                        }
                        if(!$scope.disabled_lawyerNo){
                            if(!$scope.lawyerNo){
                                showCheck('请输入律师执业证号');
                                return;
                            }
                        }
                        if(!$scope.disabled_lawfirmName){
                            if(!$scope.lawfirmName){
                                showCheck('请输入律所名称');
                                return;
                            }
                        }
                        userExt4Lawyer()
                    }else {
                        setStep(nextStep)
                    }
                }else{
                    if(!$scope.disabled_userName||!$scope.disabled_idType||!$scope.disabled_idNo){
                        if(!$scope.disabled_userName){
                            if(!$scope.userName){
                                showCheck('请输入姓名');
                                return;
                            }
                        }
                        if(!$scope.disabled_idType){
                            if(!$scope.idType){
                                showCheck('请选择证件类型');
                                return;
                            }else{

                            }
                        }
                        if(!$scope.disabled_idNo){
                            if(!$scope.idNo){
                                showCheck('请输入证件号');
                                return;
                            }
                        }
                        userExt()
                    }else {
                        setStep(nextStep)
                    }
                }
            }else if(nextStep==='3'){
                if(!$scope.caseTypeId){
                    showCheck('请选择案件类型');
                }else if(!$scope.creditorName){
                    showCheck('原告不能为空');
                }else if(!$scope.debtorName){
                    showCheck('被告不能为空');
                }else if(!$scope.caseStageId){
                    showCheck('案件阶段不能为空');
                }else if(!$scope.courtName){
                    showCheck('管辖法院不能为空');
                }else if(_SYT_util.isErrorAmount($scope.caseAmt+'')){
                    showCheck('案件标的有误');
                }else if(Number($scope.caseAmt+'')>9999999999){
                    showCheck('案件标的过长');
                }else if($scope.show_caseNo&&!$scope.caseNo){
                    showCheck('案号不能为空');
                }else if($scope.expectClosePeriod &&_SYT_util.isErrorAmount($scope.expectClosePeriod+'')){
                    showCheck('拟结案期限有误');
                }else if(Number($scope.expectClosePeriod+'')>24){
                    showCheck('拟结案期限过长');
                }else if($scope.specLawyerMobileNo && !_SYT_util.isValidNo($scope.specLawyerMobileNo+'')){
                    showCheck('手机号有误');
                }else{
                    submitCaseInfo();
                }
            }else if(nextStep==='4'){
                if($scope.expectClosePeriod && _SYT_util.isErrorAmount($scope.expectClosePeriod+'')){
                    showCheck('拟结案期限有误');
                }else if($scope.specLawyerMobileNo && !_SYT_util.isValidNo($scope.specLawyerMobileNo+'')){
                    showCheck('手机号有误');
                }else{
                    submitCaseInfo();
                }
            }else {
                setStep(nextStep)
            }
        }
        var showCheck=function (text){
            $scope.$emit("promptAlertMsg",text);
            $scope.$emit("showCollect",true);
            $timeout(function(){
                $scope.$emit("showCollect",false);
            },transData.promptTime);
        };
        $scope.$on('backAllButtonClick',function () {
            if($scope.step1){
                history.back()
            }else if($scope.step2){
                setStep('1');
                $scope.$emit('flag-tag','73-0');
            }else if($scope.step3){
                setStep('2')
            }else if($scope.step4){
                history.back()
            }
        });
        $scope.$on('topNavEditTextEvent',function () {
            if(resultData.loginUserData != "" && resultData.loginUserData != null){
                if(resultData.loginUserData.idNo != "" && resultData.loginUserData.idNo != null){
                    $timeout(function(){
                        $scope.$emit("goNext","/personalInfo");
                    },300);
                }else{
                    $timeout(function(){
                        // $scope.$emit("goNext","/completePtData");
                        $scope.$emit("goNext","/completeData");
                    },300);
                }
            }else{
                $timeout(function(){
                    // $scope.$emit("goNext","/completePtData");
                    $scope.$emit("goNext","/completeData");
                },300);
            }
        });

        if(transData.storage_baseData.queryCaseTypeList&&transData.storage_baseData.queryCaseStageList&&transData.storage_baseData.queryFundUseList&&transData.storage_baseData.queryDocKindList){
            $scope.caseTypeList=transData.storage_baseData.queryCaseTypeList.caseTypeList;
            $scope.caseStageList=transData.storage_baseData.queryCaseStageList.caseStageList;
            var docKindList=[];
            transData.storage_baseData.queryDocKindList.docKindList.forEach(function (item,i) {
                if(item.docGroup==='apply'){
                    docKindList.push(item);
                }
            });
            $scope.docKindList=docKindList;
        }else {
            getBaseData(['queryCaseTypeList','queryCaseStageList','queryFundUseList','queryDocKindList']);
        }
        var getBaseData=function (list) {
            var step=0;
            var exec=function () {
                getBaseData_query(list[step],function (next) {
                    if(next){
                        exec()
                    }
                },list[++step])
            }
            exec()
        };
        var getBaseData_query=function(name,suCallBack,next){
            var headerInfo = {},bizInfo = {};
            headerInfo.pageNum = '';
            headerInfo.pageSize = '';
            headerInfo.sessionId = transData.sessionId;
            bizProxy.queryProxyBizData(name,headerInfo,bizInfo,function(tempData){
                    if(tempData.body != '{}'){
                        $timeout(function(){
                            console.log(name+' : ',JSON.parse(tempData.body));
                            transData.storage_baseData[name]=JSON.parse(tempData.body);
                            localStorage.setItem('storage_baseData',JSON.stringify(transData.storage_baseData));
                            suCallBack(next);
                        },0);
                    }
                },
                function(data){
                    console.log(data);
                    if(data.errorMsg){
                        $scope.$emit("loadingChange",false);
                        $scope.$emit("promptAlertMsg",data.errorMsg);
                        $scope.$emit("showCollect",true);
                        $timeout(function(){
                            $scope.$emit("showCollect",false);
                        },transData.promptTime);
                    }
                });
        }


        $scope.scrollToTop=function(ele){
            if(_YTG_IOSorANDROID.systemJudge()==='Android'){
                console.log(ele,document.querySelector(ele).offsetTop)
                var offsetTop=document.querySelector(ele).offsetTop;
                if(offsetTop){
                    //document.querySelector('#applyRisk_scroll').scrollTop=offsetTop-50;
                    _fire_eleSorollToTarget('#applyRisk_scroll',offsetTop-50,300)
                }
            }
        }
        function submitCaseInfo(){
            var headerInfo = {},bizInfo = {};
            headerInfo.pageNum = '';
            headerInfo.pageSize = '';
            headerInfo.sessionId = transData.sessionId;

            bizInfo.caseTypeId=$scope.caseTypeId+'';
            bizInfo.creditorName=$scope.creditorName+'';
            bizInfo.debtorName=$scope.debtorName+'';
            bizInfo.caseStageId=$scope.caseStageId+'';
            bizInfo.courtName=$scope.courtName+'';
            bizInfo.caseAmt=$scope.caseAmt+'';

            if($scope.isSpecLawyer){
                bizInfo.isSpecLawyer=$scope.isSpecLawyer+'';
            }
            if($scope.specLawyerName){
                bizInfo.specLawyerName=$scope.specLawyerName+'';
            }
            if($scope.specLawyerMobileNo){
                bizInfo.specLawyerMobileNo=$scope.specLawyerMobileNo+'';
            }
            if($scope.caseMemo){
                bizInfo.caseMemo=$scope.caseMemo+'';
            }
            var list=transData.storage_baseData.queryCaseStageList.caseStageList;
            var __caseStageName='';
            for(var i=0;i<list.length;i++){
                if(list[i].caseStageId==$scope.caseStageId){
                    __caseStageName=list[i].caseStageName;
                    break
                }
            }
            if(transData.caseBizModeFormStep1){
                bizInfo.caseBizMode=transData.caseBizModeFormStep1;
                transData.caseBizModeFormStep1='';
            }else {
                if(__caseStageName==='结案'||__caseStageName==='执行'){
                    bizInfo.caseBizMode='3'
                }else {
                    bizInfo.caseBizMode='1'
                }
            }
            if(__caseStageName!=='未立案'){
                bizInfo.caseNo=$scope.caseNo;
                bizInfo.expectClosePeriod=$scope.expectClosePeriod||'';
            }else {
                bizInfo.caseNo='';
                bizInfo.expectClosePeriod='';
            }
            if(__caseStageName==='执行'){
                bizInfo.referCaseNo=$scope.referCaseNo||'';
                bizInfo.judgeName=$scope.judgeName||'';
                bizInfo.havePropertyClue=$scope.havePropertyClue||'';
            }else {
                bizInfo.referCaseNo='';
                bizInfo.judgeName='';
                bizInfo.havePropertyClue='';
            }
            console.log(bizInfo);
            //return;
            $scope.$emit("loadingChange",true);
            bizProxy.queryProxyBizData("submitCaseInfo",headerInfo,bizInfo,
                function(tempData){
                    $scope.$emit("loadingChange",false);
                    console.log(tempData);
                    setStep('4')
                },function(data){
                    $scope.$emit("loadingChange",false);
                    console.log(data);
                    if(data.errorMsg){
                        $scope.$emit("promptAlertMsg",data.errorMsg);
                        $scope.$emit("showCollect",true);
                        $timeout(function(){
                            $scope.$emit("showCollect",false);
                        },transData.promptTime);
                    }
                });
        }


        //调用代理提交律师用户完善资料
        function userExt4Lawyer(){
            var headerInfo = {},bizInfo = {};
            headerInfo.pageNum = '';
            headerInfo.pageSize = '';
            headerInfo.sessionId = transData.sessionId;

            if(!$scope.disabled_userName){
                bizInfo.userName=$scope.userName
            }
            if(!$scope.disabled_idType){
                bizInfo.idType=$scope.idType
            }
            if(!$scope.disabled_idNo){
                bizInfo.idNo=$scope.idNo
            }
            if(!$scope.disabled_lawyerNo){
                bizInfo.lawyerNo=$scope.lawyerNo
            }
            if(!$scope.disabled_lawfirmName){
                bizInfo.lawfirmName=$scope.lawfirmName
            }
            console.log(bizInfo);
            $scope.$emit("loadingChange",true);
            bizProxy.queryProxyBizData("userExt4Lawyer",headerInfo,bizInfo,
                function(tempData){//SUCCESS
                    console.log(tempData);
                    $scope.$emit("loadingChange",false);
                    if(tempData.isSuccess==='T'){
                        setStep('2');
                        assignmentData(tempData);
                    }
                },function(data){
                    console.log(data)
                    $scope.$emit("loadingChange",false);
                    if(data.errorMsg){
                        $scope.$emit("promptAlertMsg",data.errorMsg);
                        $scope.$emit("showCollect",true);
                        $timeout(function(){
                            $scope.$emit("showCollect",false);
                        },transData.promptTime);
                    }
                });
        }


        //调用代理提交普通用户完善资料
        function userExt(){
            var headerInfo = {},bizInfo = {};
            headerInfo.pageNum = '';
            headerInfo.pageSize = '';
            headerInfo.sessionId = transData.sessionId;

            if(!$scope.disabled_userName){
                bizInfo.userName=$scope.userName
            }
            if(!$scope.disabled_idType){
                bizInfo.idType=$scope.idType
            }
            if(!$scope.disabled_idNo){
                bizInfo.idNo=$scope.idNo
            }
            $scope.$emit("loadingChange",true);
            bizProxy.queryProxyBizData("userExt",headerInfo,bizInfo,
                function(tempData){
                    console.log(tempData);
                    $scope.$emit("loadingChange",false);
                    if(tempData.isSuccess==='T'){
                        setStep('2');
                        assignmentData(tempData);
                    }
                },function(data){
                    console.log(data)
                    $scope.$emit("loadingChange",false);
                    if(data.errorMsg){
                        $scope.$emit("promptAlertMsg",data.errorMsg);
                        $scope.$emit("showCollect",true);
                        $timeout(function(){
                            $scope.$emit("showCollect",false);
                        },transData.promptTime);
                    }
                });
        }
        //-------------------------------------------------------------------------------------
        /*//整理省市数据
        var provinceList = new Array();
        var cityListTemp = new Array();
        var districtTemp = new Array();
        collateData();//整理列表数据

        //申请人姓名
        if(resultData.loginUserData.userName != "" && resultData.loginUserData.userName != null){
            $scope.applyName = resultData.loginUserData.userName;
        }else{
            $scope.applyName = "";
        }

        //身份证号
        if(resultData.loginUserData.idNo != "" && resultData.loginUserData.idNo != null){
            $scope.idCardNo = resultData.loginUserData.idNo;
        }else{
            $scope.idCardNo = "";
        }

        //执业证号
        if(resultData.loginUserData.lawyerNo != "" && resultData.loginUserData.lawyerNo != null){
            $scope.practiceNo = resultData.loginUserData.lawyerNo;
        }else{
            $scope.practiceNo = "";
        }

        $scope.lawyerAreaName = "";//律所名称

        //联系方式
        if(resultData.loginUserData.mobileNo != "" && resultData.loginUserData.mobileNo != null){
            $scope.telNo = resultData.loginUserData.mobileNo;
        }else{
            $scope.telNo = "";
        }

        //联系地址
        $scope.provinceName = "",$scope.cityName ="",$scope.districtName = "";$scope.detailAddr = "";

        //原告
        $scope.prosecutor = "";

        //被告
        $scope.accused = "";

        //案由
        $scope.causeActionList = [{'name':'合同纠纷','val':'1'},
            {'name':'股权纠纷','val':'2'},
            {'name':'侵权赔偿案件','val':'3'},
            {'name':'人身损害及其他','val':'4'}
        ]
        $scope.describeCase = "";

        //案情描述
//    	$scope.describeCase = "";

        //案件进展情况
        $scope.caseProgress = "";

        //索赔金额
        $scope.claimAmt = "";

        //以往索赔
        $scope.oldClaimAmt = "";

        //本案预计获赔
        $scope.thisClaimAmt = "";

        //案件所在地
        $scope.provinceName1 = "",$scope.cityName1 ="",$scope.districtName1 = "";

        //管辖法院
        $scope.obedientLawer = "";

        //拟结案期限
        $scope.closeCaseList = [{'name':'1-6个月','val':'1'},
            {'name':'6-9个月','val':'2'},
            {'name':'9-12个月','val':'3'},
            {'name':'12-15个月','val':'4'},
            {'name':'15个月以上','val':'5'}
        ];
        $scope.closeDate = "";

        //需投资总金额
        $scope.investAllAmt = "";

        //预计放款时间
        $scope.extendLoanDate = '';

        //收款人帐号
        if(resultData.loginUserData.accountNo != "" && resultData.loginUserData.accountNo != null){
            $scope.bankCardNo = resultData.loginUserData.accountNo;
        }else{
            $scope.bankCardNo = "";
        }

        //银行支行
        if(resultData.loginUserData.accountNo != "" && resultData.loginUserData.accountNo != null){
            $scope.branchName = resultData.loginUserData.branchName;
        }else{
            $scope.branchName = "";
        }

        //账户名称
        if(resultData.loginUserData.accountNo != "" && resultData.loginUserData.accountNo != null){
            $scope.accountName =resultData.loginUserData.accountName;
        }else{
            $scope.accountName = "";
        }


        //收款银行名称
        if(resultData.loginUserData.bankName != "" && resultData.loginUserData.bankName != null){
            $scope.bankCardName = resultData.loginUserData.bankName;
        }else{
            $scope.bankCardName = "";
        }



//    	bizInfo.courtProvince = ($scope.provinceName != "" && $scope.provinceName != null)?($scope.provinceName).province : "";
//    	bizInfo.courtCity = ($scope.cityName != "" && $scope.cityName != null)?($scope.cityName).city : "";
//    	bizInfo.courtCounty = ($scope.districtName != "" && $scope.districtName != null)?($scope.districtName).district : "";

        //显示省份
        $scope.provinceData = provinceList;
        //显示城市
        $scope.clickCity = function(data,flag){
            var cityList = new Array();
            var provinceName = data.province;
            for(var i=0;i<cityListTemp.length;i++){
                if(cityListTemp[i].province == provinceName){
                    var tempData = {'city': cityListTemp[i].city};
                    cityList.push(tempData);
                }
            }
            if(flag === '0'){
                $scope.cityData = cityList;
            }else if(flag === '1'){
                $scope.cityData1 = cityList;
            }else if(flag === '2'){
//    			$scope.cityData2 = cityList;
            }

        }
        //显示地区
        $scope.clickArea = function(data,flag) {
            var districtList = new Array();
            var districtList1 = new Array();
            var cityName = data.city;
            for(var i=0;i<districtTemp.length;i++){
                if(districtTemp[i].city == cityName){
                    districtList = districtTemp[i].district;
                    break;
                }
            }
            for(var i=0;i< districtList.length;i++){
                var tempData = {'district':districtList[i]};
                districtList1.push(tempData);
            }
            if(flag === '0'){
                $scope.districtData = districtList1;
            }else if(flag === '1'){
                $scope.districtData1 = districtList1;
            }else if(flag === '2'){
//    			$scope.districtData2 = districtList1;
            }

        }

        //点击提交信息
        $scope.goNext = function(){
            if(! $scope.applyName){
                $scope.$emit("promptAlertMsg","申请人不能为空");
                $scope.$emit("showCollect",true);
                $timeout(function(){
                    $scope.$emit("showCollect",false);
                },transData.promptTime);
                return;
            }
//    		else if(! $scope.idCardNo){
//    			$scope.$emit("promptAlertMsg","身份证号不能为空");
//    			$scope.$emit("showCollect",true);
//    			$timeout(function(){
//    				$scope.$emit("showCollect",false);
//    			},transData.promptTime);
//                return;
//    		}
            else if(! $scope.practiceNo){
                $scope.$emit("promptAlertMsg","律师执业证号不能为空");
                $scope.$emit("showCollect",true);
                $timeout(function(){
                    $scope.$emit("showCollect",false);
                },transData.promptTime);
                return;
            }else if(isNaN($scope.practiceNo *1)){
                $scope.$emit("promptAlertMsg","律师执业证号格式不正确");
                $scope.$emit("showCollect",true);
                $timeout(function(){
                    $scope.$emit("showCollect",false);
                },transData.promptTime);
                return;
            }else if(! $scope.lawyerAreaName){
                $scope.$emit("promptAlertMsg","律所名称不能为空");
                $scope.$emit("showCollect",true);
                $timeout(function(){
                    $scope.$emit("showCollect",false);
                },transData.promptTime);
                return;
            }else if(! _SYT_util.isValidNo($scope.telNo)){
                $scope.$emit("promptAlertMsg","手机号格式不正确");
                $scope.$emit("showCollect",true);
                $timeout(function(){
                    $scope.$emit("showCollect",false);
                },transData.promptTime);
                return;
            }else if(! ($scope.provinceName).province){
                $scope.$emit("promptAlertMsg","联系地址省不能为空");
                $scope.$emit("showCollect",true);
                $timeout(function(){
                    $scope.$emit("showCollect",false);
                },transData.promptTime);
                return;
            }else if(! ($scope.cityName).city){
                $scope.$emit("promptAlertMsg","联系地址市不能为空");
                $scope.$emit("showCollect",true);
                $timeout(function(){
                    $scope.$emit("showCollect",false);
                },transData.promptTime);
                return;
            }else if(! ($scope.districtName).district){
                $scope.$emit("promptAlertMsg","联系地址区\/县不能为空");
                $scope.$emit("showCollect",true);
                $timeout(function(){
                    $scope.$emit("showCollect",false);
                },transData.promptTime);
                return;
            }else if(! $scope.detailAddr){
                $scope.$emit("promptAlertMsg","联系地址详细不能为空");
                $scope.$emit("showCollect",true);
                $timeout(function(){
                    $scope.$emit("showCollect",false);
                },transData.promptTime);
                return;
            }else if(! $scope.prosecutor){
                $scope.$emit("promptAlertMsg","原告不能为空");
                $scope.$emit("showCollect",true);
                $timeout(function(){
                    $scope.$emit("showCollect",false);
                },transData.promptTime);
                return;
            }else if(! $scope.accused){
                $scope.$emit("promptAlertMsg","被告不能为空");
                $scope.$emit("showCollect",true);
                $timeout(function(){
                    $scope.$emit("showCollect",false);
                },transData.promptTime);
                return;
            }else if(! $scope.describeCase){
                $scope.$emit("promptAlertMsg","案由不能为空");
                $scope.$emit("showCollect",true);
                $timeout(function(){
                    $scope.$emit("showCollect",false);
                },transData.promptTime);
                return;
            }else if(! $scope.caseProgress){
                $scope.$emit("promptAlertMsg","案件进展不能为空");
                $scope.$emit("showCollect",true);
                $timeout(function(){
                    $scope.$emit("showCollect",false);
                },transData.promptTime);
                return;
            }else if(! $scope.claimAmt){
                $scope.$emit("promptAlertMsg","索赔金额格式不正确");
                $scope.$emit("showCollect",true);
                $timeout(function(){
                    $scope.$emit("showCollect",false);
                },transData.promptTime);
                return;
            }else if(! $scope.oldClaimAmt){
                $scope.$emit("promptAlertMsg","以往同类案件索赔格式不正确");
                $scope.$emit("showCollect",true);
                $timeout(function(){
                    $scope.$emit("showCollect",false);
                },transData.promptTime);
                return;
            }else if(! $scope.thisClaimAmt){
                $scope.$emit("promptAlertMsg","本案预计索赔格式不正确");
                $scope.$emit("showCollect",true);
                $timeout(function(){
                    $scope.$emit("showCollect",false);
                },transData.promptTime);
                return;
            }else if(! ($scope.provinceName1).province){
                $scope.$emit("promptAlertMsg","管辖法院省不能为空");
                $scope.$emit("showCollect",true);
                $timeout(function(){
                    $scope.$emit("showCollect",false);
                },transData.promptTime);
                return;
            }else if(! ($scope.cityName1).city){
                $scope.$emit("promptAlertMsg","管辖法院市不能为空");
                $scope.$emit("showCollect",true);
                $timeout(function(){
                    $scope.$emit("showCollect",false);
                },transData.promptTime);
                return;
            }else if(! ($scope.districtName1).district){
                $scope.$emit("promptAlertMsg","管辖法院区\/县不能为空");
                $scope.$emit("showCollect",true);
                $timeout(function(){
                    $scope.$emit("showCollect",false);
                },transData.promptTime);
                return;
            }else if(! $scope.obedientLawer){
                $scope.$emit("promptAlertMsg","管辖法院称不能为空");
                $scope.$emit("showCollect",true);
                $timeout(function(){
                    $scope.$emit("showCollect",false);
                },transData.promptTime);
                return;
            }else if(! $scope.closeDate){
                $scope.$emit("promptAlertMsg","拟结案期限不能为空");
                $scope.$emit("showCollect",true);
                $timeout(function(){
                    $scope.$emit("showCollect",false);
                },transData.promptTime);
                return;
            }else if(! $scope.investAllAmt){
                $scope.$emit("promptAlertMsg","需投资总金额格式不正确");
                $scope.$emit("showCollect",true);
                $timeout(function(){
                    $scope.$emit("showCollect",false);
                },transData.promptTime);
                return;
            }else if(! $scope.extendLoanDate){
                $scope.$emit("promptAlertMsg","期望放款日期不能为空");
                $scope.$emit("showCollect",true);
                $timeout(function(){
                    $scope.$emit("showCollect",false);
                },transData.promptTime);
                return;
            }else if(! $scope.bankCardName){
                $scope.$emit("promptAlertMsg","银行名称不能为空");
                $scope.$emit("showCollect",true);
                $timeout(function(){
                    $scope.$emit("showCollect",false);
                },transData.promptTime);
                return;
            }else if(! $scope.branchName){
                $scope.$emit("promptAlertMsg","银行支行名称不能为空");
                $scope.$emit("showCollect",true);
                $timeout(function(){
                    $scope.$emit("showCollect",false);
                },transData.promptTime);
                return;
            }else if(! $scope.accountName){
                $scope.$emit("promptAlertMsg","账户名称不能为空");
                $scope.$emit("showCollect",true);
                $timeout(function(){
                    $scope.$emit("showCollect",false);
                },transData.promptTime);
                return;
            }else if(! _YHC_util.luhmCheck($scope.bankCardNo)){
                $scope.$emit("promptAlertMsg","银行账号格式不正确");
                $scope.$emit("showCollect",true);
                $timeout(function(){
                    $scope.$emit("showCollect",false);
                },transData.promptTime);
                return;
            }
            subApplyData();
        }

        //提交申请资料
        function subApplyData(){
            var headerInfo = {},bizInfo = {};
            headerInfo.pageNum = '';
            headerInfo.pageSize = '';
            headerInfo.sessionId = transData.sessionId;

            bizInfo.inviteCode = resultData.loginUserData.inviteCode;
            bizInfo.lawyerNo = $scope.practiceNo;
            bizInfo.applyUserName = $scope.applyName;
            bizInfo.lawyerCompName = $scope.lawyerAreaName;
            bizInfo.mobileNo = $scope.telNo;
            bizInfo.province = ($scope.provinceName).province;
            bizInfo.city = ($scope.cityName).city;
            bizInfo.county = ($scope.districtName).district;
            bizInfo.address = $scope.detailAddr;
            bizInfo.creditorName = $scope.prosecutor;
            bizInfo.debtorName = $scope.accused;
            bizInfo.caseMemo = $scope.describeCase;
            bizInfo.caseSituation = $scope.caseProgress;
            bizInfo.claimAmt = $scope.claimAmt;
            bizInfo.historyAmt = $scope.oldClaimAmt;
            bizInfo.expectAmt = $scope.thisClaimAmt;
            bizInfo.courtProvince = ($scope.provinceName1).province;
            bizInfo.courtCity = ($scope.cityName1).city;
            bizInfo.courtCountry = ($scope.districtName1).district;
            bizInfo.courtName = $scope.obedientLawer;
            bizInfo.closePeriod = $scope.closeDate;
            bizInfo.totalAmt = $scope.investAllAmt;
            bizInfo.expectCreditDate = ($scope.extendLoanDate).replace(new RegExp(/-/g),'');
            bizInfo.bankName = $scope.bankCardName;
            bizInfo.accountNo = $scope.bankCardNo;
            bizInfo.branchName = $scope.branchName;
            bizInfo.accountName = $scope.accountName;

            //	bizInfo.rcScore = transData.score*1;
            //	bizInfo.rcDetail = transData.rcDetail;



            $scope.$emit("loadingChange",true);
            bizProxy.queryProxyBizData("vcAgentApply",headerInfo,bizInfo,
                function(tempData){//SUCCESS
                    $scope.$emit("loadingChange",false);
                    //	$timeout(function(){
                    //		FIREFLY("提交成功,请等待平台审核！", "我方会在2个工作日内审核完毕","",function(){
                    //			$timeout(function(){
                    //				$scope.$emit("goNext","/applySurvey");
                    //			},0);
                    //		});
                    //	},100);
                    console.log(tempData);
                    var investApplyId = JSON.parse(tempData.body);
                    var applyId  = investApplyId.applyId;
                    $scope.$emit("goNext","/applySurvey/" + applyId);
                },function(data){
                    if(data != ""){//FAIL
                        $scope.$emit("loadingChange",false);
                        if(data.errorCode == ERROR_CODE.noLogin){
                            FIREFLY("", data.errorMsg,"",function(){
                                //调用退出登录
                                transData.mobileNo = "";
                                transData.password = "";
                                transData.sessionId = "";
                                transData.userType = "";
                                resultData.loginUserData = "";
                                resultData.loginResultData = "";
                                $timeout(function(){
                                    $scope.$emit("goNext","/mine");
                                },0);
                            });
                        }else{
                            $scope.$emit("promptAlertMsg",data.errorMsg);
                            $scope.$emit("showCollect",true);
                            $timeout(function(){
                                $scope.$emit("showCollect",false);
                            },transData.promptTime);
                        }
                    }else{
                        $scope.$emit("loadingChange",false);
                        $scope.$emit("promptAlertMsg","连接超时");
                        $scope.$emit("showCollect",true);
                        $timeout(function(){
                            $scope.$emit("showCollect",false);
                        },transData.promptTime);
                    }
                });
        }



        //整理省份数据
        function collateData() {
            cityListTemp = new Array();
            districtTemp = new Array();
            for(var key in cityData.addressDetail){
                var tempData = {"province":key};
                provinceList.push(tempData);
                collateCity(key,cityData.addressDetail[key]);
            }
        }
        //整理城市数据
        function collateCity(data1,data2) {
            for(var key in data2){
                var tempList = {'province':data1,'city': key};
                cityListTemp.push(tempList);
                districtCity(key,data2[key]);
            }
        }
        //整理县区数据
        function districtCity(data1,data2){
            var tempList = {'city': data1,'district': data2};
            districtTemp.push(tempList);
        }

*/

        $scope.$apply();
    }];
});